<div id="inline2">
<h2><span class="cur">密码修改</span></h2>
<form action="index.php/user/modify_pswd" method="post" id="myform">
<table>
        <tr><th colspan="5" style="height:16px; line-height:16px;">&nbsp;</th></tr>
        <tr>
        	<td class="name">旧密码：</td>
            <td><input type="password" id="ago_pswd"></td>
        </tr>
        <tr>
        	<td class="name">新密码：</td>
            <td><input type="password" id="pswd" name="pswd"></td>
        </tr>
        <tr>
            <td class="name">确认密码：</td>
            <td><input type="password" id="pswd1" name="pswd1"></td>
        </tr>
        <tr><td colspan="5">&nbsp;</td></tr>
        <tr><td colspan="2"><input class="p_but_2" type="button" value="保存更改"></td></tr>
    </table>
    </form>
</div>


<script type="text/javascript">
	$(document).ready(function(){
		$("#inline2 .p_but_2").click(function(){
			var pswd = $("#ago_pswd").val();
			if(!pswd){
				alert('请输入旧密码');
				return false;
			}else{
				$.post("index.php/user/check_ago_password", { pswd: pswd },
						   function(data){
					   		if(data){
					   			check();
						   	}else{
								alert('旧密码没有匹配,请重新输入');
								$("#ago_pswd").val('');
								$("#ago_pswd").focus();
								return false;
							}
				});
			}
		});

function check(){
	var pasd = $("#pswd").val();
	var pasd1 = $("#pswd1").val();
	if(!pasd || !pasd1){
		alert("密码不能为空");
		return false;
	}else{
		if(pasd != pasd1){
			alert("两次输入密码不相同");
			return false;
			}else{
			  var length = pasd.length;
			  if(length < 5){
					alert("密码不能小于5位");  
					return false;
				}else{
					$("#myform").submit();
				}
			}
		}
	
}
	});	

</script>